#include "StdAfx.h"
#include "TestFloorManager.h"

#include <cppunit\TestAssert.h>

#include "..\Elevator\Floor.h"
#include "..\Elevator\FloorsManager.h"

CPPUNIT_TEST_SUITE_REGISTRATION(TestFloorManager);

TestFloorManager::TestFloorManager(void)
{
}

TestFloorManager::~TestFloorManager(void)
{
}

void TestFloorManager::TestElevatorStartFrom1stFloor5FloorsCapacity2()
{
	const size_t capacity(2);
	const size_t floorsNum(5);
	CFloorsManager manager(capacity);
	manager.GenerateFloors(floorsNum);

	CPPUNIT_ASSERT_EQUAL(floorsNum, manager.GetFloors().size());

	std::vector<size_t> floor1, floor2, floor3, floor4, floor5;
	floor1.push_back(4);
	floor1.push_back(2);

	floor2.push_back(0);
	floor2.push_back(2);
	floor2.push_back(3);
	floor2.push_back(4);

	floor3.push_back(1);
	floor3.push_back(0);
	floor3.push_back(4);

	floor4.push_back(0);

	floor5.push_back(1);
	floor5.push_back(2);
	floor5.push_back(2);
	floor5.push_back(0);

	manager.ImportPassengersToFloor(0, floor1);
	manager.ImportPassengersToFloor(1, floor2);
	manager.ImportPassengersToFloor(2, floor3);
	manager.ImportPassengersToFloor(3, floor4);
	manager.ImportPassengersToFloor(4, floor5);
	manager.Start();

	for (size_t i=0; i<manager.GetFloors().size(); ++i)
		CPPUNIT_ASSERT(manager.GetFloors().at(i)->GetIncomingPassengers().empty());
}

void TestFloorManager::TestElevatorStartFromLastFloor10FloorsCapacity10()
{
	const size_t capacity(5);
	const size_t floorsNum(10);
	CFloorsManager manager(capacity);
	manager.GenerateFloors(floorsNum);

	CPPUNIT_ASSERT_EQUAL(floorsNum, manager.GetFloors().size());

	std::vector<size_t> floor1, floor2, floor3, floor4, floor5, floor6, floor7, floor8, floor9, floor10;
	floor1.push_back(9);
	floor1.push_back(3);
	floor1.push_back(1);

	floor2.push_back(0);
	floor2.push_back(2);
	floor2.push_back(3);
	floor2.push_back(4);
	floor2.push_back(6);

	floor3.push_back(1);
	floor3.push_back(0);
	floor3.push_back(2);
	floor3.push_back(9);

	floor4.push_back(0);
	floor4.push_back(0);
	floor4.push_back(8);
	floor4.push_back(7);

	floor5.push_back(1);
	floor5.push_back(2);
	floor5.push_back(2);
	floor5.push_back(0);

	floor6.push_back(0);
	floor6.push_back(2);
	floor6.push_back(9);
	floor6.push_back(1);

	floor7.push_back(9);
	floor7.push_back(0);
	floor7.push_back(1);
	floor7.push_back(2);

	floor8.push_back(6);
	floor8.push_back(6);
	floor8.push_back(7);
	floor8.push_back(9);

	floor9.push_back(1);
	floor9.push_back(2);
	floor9.push_back(3);
	floor9.push_back(4);

	floor10.push_back(5);
	floor10.push_back(6);
	floor10.push_back(7);
	floor10.push_back(8);
	floor10.push_back(9);
	floor10.push_back(0);
	floor10.push_back(1);

	manager.ImportPassengersToFloor(0, floor1);
	manager.ImportPassengersToFloor(1, floor2);
	manager.ImportPassengersToFloor(2, floor3);
	manager.ImportPassengersToFloor(3, floor4);
	manager.ImportPassengersToFloor(4, floor5);
	manager.ImportPassengersToFloor(5, floor6);
	manager.ImportPassengersToFloor(6, floor7);
	manager.ImportPassengersToFloor(7, floor8);
	manager.ImportPassengersToFloor(8, floor9);
	manager.ImportPassengersToFloor(9, floor10);
	manager.Start();

	for (size_t i=0; i<manager.GetFloors().size(); ++i)
		CPPUNIT_ASSERT(manager.GetFloors().at(i)->GetIncomingPassengers().empty());
}